@pushd %~dp0%

@set DEVENV=%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe
@IF NOT EXIST "%DEVENV%" SET DEVENV=%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\Common7\IDE\VSWinExpress.exe
@set ZIP=%ProgramFiles%\7-Zip\7z.exe

"%DEVENV%" /build "Release|ARM" Microsoft.Media.CaptureClient.Sample.sln
"%DEVENV%" /build "Release|Win32" Microsoft.Media.CaptureClient.Sample.sln
"%DEVENV%" /build "Release|x64" Microsoft.Media.CaptureClient.Sample.sln

cd vsix
cd win81

rmdir /s /q "Redist\"
rmdir /s /q "References\"

mkdir "Redist"
mkdir "Redist\CommonConfiguration"
mkdir "Redist\CommonConfiguration\neutral"
mkdir "Redist\CommonConfiguration\ARM"
mkdir "Redist\CommonConfiguration\x64"
mkdir "Redist\CommonConfiguration\x86"
mkdir "References"
mkdir "References\CommonConfiguration"
mkdir "References\CommonConfiguration\neutral"
mkdir "References\CommonConfiguration\ARM"
mkdir "References\CommonConfiguration\x64"
mkdir "References\CommonConfiguration\x86"

copy "..\..\Release\Microsoft.Media.FragmentedMediaSink.Windows\Microsoft.Media.FragmentedMediaSink.winmd"				"References\CommonConfiguration\neutral\"
copy "..\..\Release\Microsoft.Media.FragmentedMediaSink.Windows\Microsoft.Media.FragmentedMediaSink.pri"				"Redist\CommonConfiguration\neutral\"
copy "..\..\ARM\Release\Microsoft.Media.FragmentedMediaSink.Windows\Microsoft.Media.FragmentedMediaSink.Windows.dll"	"Redist\CommonConfiguration\ARM\"
copy "..\..\x64\Release\Microsoft.Media.FragmentedMediaSink.Windows\Microsoft.Media.FragmentedMediaSink.Windows.dll"	"Redist\CommonConfiguration\x64\"
copy "..\..\Release\Microsoft.Media.FragmentedMediaSink.Windows\Microsoft.Media.FragmentedMediaSink.Windows.dll"		"Redist\CommonConfiguration\x86\"

copy "..\..\CaptureClient\Windows\bin\ARM\Release\Microsoft.Media.CaptureClient.winmd"					"References\CommonConfiguration\ARM\"
copy "..\..\CaptureClient\Windows\bin\x64\Release\Microsoft.Media.CaptureClient.winmd"					"References\CommonConfiguration\x64\"
copy "..\..\CaptureClient\Windows\bin\x86\Release\Microsoft.Media.CaptureClient.winmd"					"References\CommonConfiguration\x86\"
copy "..\..\CaptureClient\Windows\bin\ARM\Release\Microsoft.Media.CaptureClient.xml"					"References\CommonConfiguration\ARM\"
copy "..\..\CaptureClient\Windows\bin\x64\Release\Microsoft.Media.CaptureClient.xml"					"References\CommonConfiguration\x64\"
copy "..\..\CaptureClient\Windows\bin\x86\Release\Microsoft.Media.CaptureClient.xml"					"References\CommonConfiguration\x86\"
copy "..\..\CaptureClient\Windows\bin\ARM\Release\Microsoft.Media.CaptureClient.pdb"					"References\CommonConfiguration\ARM\"
copy "..\..\CaptureClient\Windows\bin\x64\Release\Microsoft.Media.CaptureClient.pdb"					"References\CommonConfiguration\x64\"
copy "..\..\CaptureClient\Windows\bin\x86\Release\Microsoft.Media.CaptureClient.pdb"					"References\CommonConfiguration\x86\"
copy "..\..\CaptureClient\Windows\bin\x86\Release\Microsoft.Media.CaptureClient.pri"					"References\CommonConfiguration\neutral\"

copy "..\..\CaptureClient\Windows\bin\ARM\Release\Microsoft.Media.IngestClient.winmd"					"References\CommonConfiguration\ARM\"
copy "..\..\CaptureClient\Windows\bin\x64\Release\Microsoft.Media.IngestClient.winmd"					"References\CommonConfiguration\x64\"
copy "..\..\CaptureClient\Windows\bin\x86\Release\Microsoft.Media.IngestClient.winmd"					"References\CommonConfiguration\x86\"
copy "..\..\CaptureClient\Windows\bin\ARM\Release\Microsoft.Media.IngestClient.xml"						"References\CommonConfiguration\ARM\"
copy "..\..\CaptureClient\Windows\bin\x64\Release\Microsoft.Media.IngestClient.xml"						"References\CommonConfiguration\x64\"
copy "..\..\CaptureClient\Windows\bin\x86\Release\Microsoft.Media.IngestClient.xml"						"References\CommonConfiguration\x86\"
copy "..\..\CaptureClient\Windows\bin\ARM\Release\Microsoft.Media.IngestClient.pdb"						"References\CommonConfiguration\ARM\"
copy "..\..\CaptureClient\Windows\bin\x64\Release\Microsoft.Media.IngestClient.pdb"						"References\CommonConfiguration\x64\"
copy "..\..\CaptureClient\Windows\bin\x86\Release\Microsoft.Media.IngestClient.pdb"						"References\CommonConfiguration\x86\"
copy "..\..\CaptureClient\Windows\bin\x86\Release\Microsoft.Media.IngestClient.pri"						"References\CommonConfiguration\neutral\"

copy "..\..\CaptureClient\Windows\bin\ARM\Release\Microsoft.Media.ISO.winmd"							"References\CommonConfiguration\ARM\"
copy "..\..\CaptureClient\Windows\bin\x64\Release\Microsoft.Media.ISO.winmd"							"References\CommonConfiguration\x64\"
copy "..\..\CaptureClient\Windows\bin\x86\Release\Microsoft.Media.ISO.winmd"							"References\CommonConfiguration\x86\"
copy "..\..\CaptureClient\Windows\bin\ARM\Release\Microsoft.Media.ISO.pdb"								"References\CommonConfiguration\ARM\"
copy "..\..\CaptureClient\Windows\bin\x64\Release\Microsoft.Media.ISO.pdb"								"References\CommonConfiguration\x64\"
copy "..\..\CaptureClient\Windows\bin\x86\Release\Microsoft.Media.ISO.pdb"								"References\CommonConfiguration\x86\"
copy "..\..\CaptureClient\Windows\bin\x86\Release\Microsoft.Media.ISO.pri"								"References\CommonConfiguration\neutral\"

"%ZIP%" a ..\AzureMediaCapture.Win81.zip "*"

cd ..\
cd wp81

rmdir /s /q "Redist\"
rmdir /s /q "References\"

mkdir "Redist"
mkdir "Redist\CommonConfiguration"
mkdir "Redist\CommonConfiguration\neutral"
mkdir "Redist\CommonConfiguration\ARM"
mkdir "Redist\CommonConfiguration\x86"
mkdir "References"
mkdir "References\CommonConfiguration"
mkdir "References\CommonConfiguration\neutral"
mkdir "References\CommonConfiguration\ARM"
mkdir "References\CommonConfiguration\x86"

copy "..\..\Release\Microsoft.Media.FragmentedMediaSink.WindowsPhone\Microsoft.Media.FragmentedMediaSink.winmd"						"References\CommonConfiguration\neutral\"
copy "..\..\Release\Microsoft.Media.FragmentedMediaSink.WindowsPhone\Microsoft.Media.FragmentedMediaSink.pri"						"Redist\CommonConfiguration\neutral\"
copy "..\..\ARM\Release\Microsoft.Media.FragmentedMediaSink.WindowsPhone\Microsoft.Media.FragmentedMediaSink.WindowsPhone.dll"		"Redist\CommonConfiguration\ARM\"
copy "..\..\Release\Microsoft.Media.FragmentedMediaSink.WindowsPhone\Microsoft.Media.FragmentedMediaSink.WindowsPhone.dll"			"Redist\CommonConfiguration\x86\"

copy "..\..\CaptureClient\WindowsPhone\bin\ARM\Release\Microsoft.Media.CaptureClient.winmd"							"References\CommonConfiguration\ARM\"
copy "..\..\CaptureClient\WindowsPhone\bin\x86\Release\Microsoft.Media.CaptureClient.winmd"							"References\CommonConfiguration\x86\"
copy "..\..\CaptureClient\WindowsPhone\bin\ARM\Release\Microsoft.Media.CaptureClient.xml"							"References\CommonConfiguration\ARM\"
copy "..\..\CaptureClient\WindowsPhone\bin\x86\Release\Microsoft.Media.CaptureClient.xml"							"References\CommonConfiguration\x86\"
copy "..\..\CaptureClient\WindowsPhone\bin\ARM\Release\Microsoft.Media.CaptureClient.pdb"							"References\CommonConfiguration\ARM\"
copy "..\..\CaptureClient\WindowsPhone\bin\x86\Release\Microsoft.Media.CaptureClient.pdb"							"References\CommonConfiguration\x86\"
copy "..\..\CaptureClient\WindowsPhone\bin\x86\Release\Microsoft.Media.CaptureClient.pri"							"References\CommonConfiguration\neutral\"

copy "..\..\CaptureClient\WindowsPhone\bin\ARM\Release\Microsoft.Media.IngestClient.winmd"							"References\CommonConfiguration\ARM\"
copy "..\..\CaptureClient\WindowsPhone\bin\x86\Release\Microsoft.Media.IngestClient.winmd"							"References\CommonConfiguration\x86\"
copy "..\..\CaptureClient\WindowsPhone\bin\ARM\Release\Microsoft.Media.IngestClient.xml"							"References\CommonConfiguration\ARM\"
copy "..\..\CaptureClient\WindowsPhone\bin\x86\Release\Microsoft.Media.IngestClient.xml"							"References\CommonConfiguration\x86\"
copy "..\..\CaptureClient\WindowsPhone\bin\ARM\Release\Microsoft.Media.IngestClient.pdb"							"References\CommonConfiguration\ARM\"
copy "..\..\CaptureClient\WindowsPhone\bin\x86\Release\Microsoft.Media.IngestClient.pdb"							"References\CommonConfiguration\x86\"
copy "..\..\CaptureClient\WindowsPhone\bin\x86\Release\Microsoft.Media.IngestClient.pri"							"References\CommonConfiguration\neutral\"

copy "..\..\CaptureClient\WindowsPhone\bin\ARM\Release\Microsoft.Media.ISO.winmd"									"References\CommonConfiguration\ARM\"
copy "..\..\CaptureClient\WindowsPhone\bin\x86\Release\Microsoft.Media.ISO.winmd"									"References\CommonConfiguration\x86\"
copy "..\..\CaptureClient\WindowsPhone\bin\ARM\Release\Microsoft.Media.ISO.pdb"										"References\CommonConfiguration\ARM\"
copy "..\..\CaptureClient\WindowsPhone\bin\x86\Release\Microsoft.Media.ISO.pdb"										"References\CommonConfiguration\x86\"
copy "..\..\CaptureClient\WindowsPhone\bin\x86\Release\Microsoft.Media.ISO.pri"										"References\CommonConfiguration\neutral\"

"%ZIP%" a ..\AzureMediaCapture.WP81.zip "*"

cd ..\
move AzureMediaCapture.Win81.zip combined\AzureMediaCapture.Win81.vsix
move AzureMediaCapture.WP81.zip combined\AzureMediaCapture.WP81.vsix

cd combined
"%ZIP%" a ..\AzureMediaCapture.zip "*"
cd ..\
move AzureMediaCapture.zip ..\AzureMediaCapture.vsix

@popd

@echo.
@pause